<html xmlns="http://www.w3.org/1999/xhtml"><head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<meta http-equiv="Content-Language" content="zh-CN"> 
<meta content="all" name="robots"> 
<meta name="description" content=""> 
<meta content="" name="keywords"> 
<title>配送设置</title> 
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/css/admin.css">
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/css/index.css"> 

 <script src="<{$siteurl}>/templates/<{$tempdir}>/public/js/jquery.js" type="text/javascript" language="javascript"></script>  
 <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/artdialog/artDialog.js?skin=wmrPopup"></script>
 <style>
 cite, blackquote, em, i {
    font-style: normal;
}
 </style>
 <script>
	$(function(){ 
	$(".popLayDiseLrad ul li .popDisRada").click(function(){
		var x = $(".popLayDiseLrad ul li .popDisRada").index(this);
		$(".popLayDiseLrad ul li .popDisRadb").eq(x).addClass("popDisRad01")
		})
	$(".popLayDiseLrad ul li .popDisRada").mousedown(function(){
		$(".popLayDiseLrad ul li .popDisRadb").removeClass("popDisRad01")
		})
	 
	$(".popLayDiseR tr td .popDisRada").click(function(){
		var x = $(".popLayDiseR tr td .popDisRada").index(this);
 		$(".popLayDiseR tr td .popDisRada i").eq(x).addClass("popDisRad01")
		})
	$(".popLayDiseR tr td .popDisRada").mousedown(function(){
		$(".popLayDiseR tr td .popDisRada i").removeClass("popDisRad01")
		})
	});
 </script>
</head>
<body>
	 <form  method="post" name="upform" action="<{ofunc type=url link="/areaadminpage/area/module/savesetps"}>" >  
	 	
	 	<div class="popLayCon ">
	 
	<div class="popLayBox">
		<div class="popLayOrdCon">
			<div class="popLayDise">
			<div style="width:600px;height:380px;OVERFLOW-Y: auto;OVERFLOW-X: hidden;">
				<div class="popLayDiseL" style="width:500px;">
					<h4>配送类型</h4>
					<div class="popLayDiseLrad">
						<ul>
							<li><input type="radio" name="sendtype" value="0" <{if $shopdetinfo['sendtype'] ==0}>checked<{/if}> class="popDisRada"><i class="popDisRadb  <{if $shopdetinfo['sendtype'] ==0}>popDisRad01<{/if}>  "></i><span>网站配送</span></li>
							<li><input type="radio"  name="sendtype" value="1" <{if $shopdetinfo['sendtype'] ==1}>checked<{/if}>" class="popDisRada"><i class="popDisRadb <{if $shopdetinfo['sendtype'] ==1}>popDisRad01<{/if}> "></i><span>店铺配送</span></li>
							<{if isset($psbopen) && $psbopen==1}><li><input type="radio" name="sendtype" value="2" <{if $shopdetinfo['sendtype'] == 2}>checked<{/if}> class="popDisRada"><i class="popDisRadb <{if $shopdetinfo['sendtype'] ==2}>popDisRad01<{/if}> "></i>配送宝<li><{/if}>
						</ul>
					</div> 
					<{if isset($psbopen) && $psbopen==1}>
					<{if empty($shopinfo['psbaccid']) }>
					<div class="popLayDiseLfee psbtype" style="display:none;">
						<ul>
							<li>
							<input type="radio" name="duijietype" value="1"  ><span>自动对接</span>
							<input type="radio" name="duijietype" value="2"  ><span>手动对接 </span>
							</li>
						</ul>
					</div> 
					
					<div class="popLayDiseLfee psselect" style="display:none;">
						<ul>
							<li>
							<select name="stationid" onchange="loadgroup();">
							</select>
							</li>
						</ul>	  
					</div>
					<div class="popLayDiseLfee psselect" style="display:none;">
						<ul>
							<li>
							<select name="psgroupid"></select>
							</li>
						</ul>	  
					</div>
					<div class="popLayDiseLfee psselect" style="display:none;">
						<ul>
							<li>
							<select name="bizdistrictid"></select>
							</li>
						</ul>	  
					</div> 
					<div class="popLayDiseLfee psselect" style="display:none;">
						<ul> 
							 <li><a href="#" onclick="doautoadd();">确认对接</a></li>
						</ul>
					</div>
					<{/if}>
					
					<div class="popLayDiseLfee psbps" <{if $shopdetinfo['sendtype'] != 2}>style="display:none;"<{/if}>>
						<ul>
						 <li><span>配送宝链接:</span><input type="text" name="psblink" value="<{$shopinfo['psblink']}>" style="width:200px;"></li>
						</ul>
					</div>
					<div class="popLayDiseLfee psbps" <{if $shopdetinfo['sendtype'] != 2}>style="display:none;"<{/if}>>
						<ul>
						 <li><span>配送宝商家id:</span><input type="text" name="psbaccid" value="<{$shopinfo['psbaccid']}>" style="width:200px;"></li>
						</ul>
					</div>
					<div class="popLayDiseLfee psbps" <{if $shopdetinfo['sendtype'] != 2}>style="display:none;"<{/if}>  >
						<ul>
						 <li><span>配送宝key:</span><input type="text" name="psbkey" value="<{$shopinfo['psbkey']}>" style="width:200px;"></li>
						</ul>
					</div>
					<div class="popLayDiseLfee psbps" <{if $shopdetinfo['sendtype'] != 2}>style="display:none;"<{/if}>>
						<ul>
						 <li><span>配送宝code:</span><input type="text" name="psbcode" value="<{$shopinfo['psbcode']}>" style="width:200px;"><span><a href="javascript:teskpsb();" id="testrestul">测试对接</a></span></li>
						</ul>
					</div> 
					<{/if}>
					<div class="popLayDiseLfee">
						<input type="hidden" value="<{$shopdetinfo['shopid']}>" name="shopid" />
							<ul>
								<li><span>配送费：</span><input type="text" name="pscost" value="<{$shopdetinfo['pscost']}>" ><span>元</span></li>
								<li  id="showbangjing"><span>配送半径：</span><input type="text"  name="pradius" value="<{$shopdetinfo['pradius']}>"  onchange="doselect();" ><span>千米</span></li>
								 
							</ul>
						 
					</div> 
					
					
					
				</div>
				</div>
				
			 
				
				
			</div> 
			
			<div class="popLayOrdBut"><input type="submit" value="保存设置"></div>
		</div>
	</div>
</div>
	 	 
	  
 
	 	 
 	 	
  </form>
<script>
var checklocation = '<{$locationtype}>';
$(function(){ 
	/*
	if(checklocation == 1){
	   
	  $('.showpesong').hide();
	  
	}else{
		$('.showbangjing').hide();
	}*/
	doselect(); 
	$('input[name="sendtype"]').bind('click',function(){
        var sendtype = $('input[name="sendtype"]:checked ').val();
        if(sendtype == 2){
			if($('.psbtype').length > 0){
				$('.psbtype').show();
			}else{ 
				$('.psbps').show();
			}
        }else{
            $('.psbps').hide();
			$('.psbtype').hide();
             
        }
    });
	$('input[name="duijietype"]').bind('click',function(){
        var sendtype = $('input[name="duijietype"]:checked ').val();
        if(sendtype == 1){ 
			$('.psbps').hide();
			$('.psselect').show(); 
			loadstation();
			
        }else{
            $('.psbps').show(); 
			$('.psselect').hide();
        }
    });
});
function doselect(){
	var bangjing = $('input[name="pradius"]').val();
	var htmls = '';
	var checkleng = Number(<{$dolenth}>);
	$('.bangjingvalue').remove();
	for(var i=0;i<bangjing;i++){
		var c = i+1; 
		if(i < checkleng){
		<{foreach from=$shopvalues key=mykey item=items}>
		  if(i == <{$mykey}>){
	     	htmls += '<li  class="bangjingvalue"><span>'+i+'-'+c+'千米配送费：</span><input type="text" name="radiusvalue'+i+'" value="<{$items}>" ><span>元</span></li>';
 	    }
		<{/foreach}>
		
	  }else{
	  	htmls += '<li  class="bangjingvalue"><span>'+i+'-'+c+'千米配送费：</span><input type="text"  name="radiusvalue'+i+'" value=""><span>元</span></li>';
 	  }
		
	}
	$('#showbangjing').after(htmls);
	//
}
function teskpsb(){ 
	var url = '<{ofunc type=url link="/areaadminpage/area/module/testpsblink/datatype/json/random/@random@"}>'; 
	 $.ajax({
	 type: 'post',
	 async:true,
	 data:{'psblink':$('input[name="psblink"]').val(),'bizid':$('input[name="psbaccid"]').val(),'psbkey':$('input[name="psbkey"]').val(),'psbcode':$('input[name="psbcode"]').val()},
	 url: url.replace('@random@', 1+Math.round(Math.random()*1000)), 
	 dataType: 'json',success: function(content) {  
		if(content.error == false){
			 $('#testrestul').html('测试成功');
		}else{
			if(content.error == true)
			{
				 $('#testrestul').html(content.msg); 
			}else{
				 $('#testrestul').html(content); 
			}
		} 
		},
	error: function(content) {   
		 $('#testrestul').html('数据获取失败'); 
	  }
   });   
}

function loadstation(){
	var url = '<{ofunc type=url link="/areaadminpage/area/module/getstaionlist/datatype/json/random/@random@"}>'; 
	$('select[name="stationid"]').html('');
	$('select[name="psgroupid"]').html('');
	$('select[name="bizdistrictid"]').html('');
	 $.ajax({
	 type: 'post',
	 async:true,
	 data:{},
	 url: url.replace('@random@', 1+Math.round(Math.random()*1000)), 
	 dataType: 'json',success: function(content) {  
		if(content.error == false){
			// $('#testrestul').html('测试成功'); 
			if(content.msg.stationlist.length > 0){
			   for(var i = 0;i<content.msg.stationlist.length;i++){
			        $('select[name="stationid"]').append('<option value="'+content.msg.stationlist[i].sid+'">'+content.msg.stationlist[i].sname+'</option>');
			   }
			} 
			setTimeout("loadgroup()",500); 
			 
		}else{
			if(content.error == true)
			{
			alert(content.msg);
				 //$('#testrestul').html(); 
			}else{
			alert(content);
				// $('#testrestul').html(content); 
			}
		} 
		},
	error: function(content) {   
		 alert('数据获取失败');// $('#testrestul').html(''); 
	  }
   });   
}
function doautoadd(){
	var url = '<{ofunc type=url link="/areaadminpage/area/module/addacounttopsb/datatype/json/random/@random@"}>'; 
	var stationid = $("select[name='stationid']").find("option:selected").val();
	var shopid = $("input[name='shopid']").val();
	var psgroupid = $("select[name='psgroupid']").find("option:selected").val();
	var bizdistrictid = $("select[name='bizdistrictid']").find("option:selected").val();
	 $.ajax({
	 type: 'post',
	 async:true,
	 data:{'stationid':stationid,'shopid':shopid,'psgroupid':psgroupid,'bizdistrictid':bizdistrictid},
	 url: url.replace('@random@', 1+Math.round(Math.random()*1000)), 
	 dataType: 'json',success: function(content) {  
		if(content.error == false){
			// $('#testrestul').html('测试成功'); 
			 location.reload();  
		}else{
			if(content.error == true)
			{
			alert(content.msg);
				 //$('#testrestul').html(); 
			}else{
			alert(content);
				// $('#testrestul').html(content); 
			}
		} 
		},
	error: function(content) {   
		 alert('数据获取失败');// $('#testrestul').html(''); 
	  }
   });  
}
function loadgroup(){
$('select[name="psgroupid"]').html('');
	$('select[name="bizdistrictid"]').html('');
	var url = '<{ofunc type=url link="/areaadminpage/area/module/getstationchild/datatype/json/random/@random@"}>'; 
	var stationid = $("select[name='stationid']").find("option:selected").val();
	 $.ajax({
	 type: 'post',
	 async:true,
	 data:{'stationid':stationid},
	 url: url.replace('@random@', 1+Math.round(Math.random()*1000)), 
	 dataType: 'json',success: function(content) {  
		if(content.error == false){
			// $('#testrestul').html('测试成功'); 
			if(content.msg.psgroup.length > 0){
			   for(var i = 0;i<content.msg.psgroup.length;i++){
			        $('select[name="psgroupid"]').append('<option value="'+content.msg.psgroup[i].id+'">'+content.msg.psgroup[i].name+'</option>');
			   }
			} 
			if(content.msg.bizdistrict.length > 0){
			   for(var i = 0;i<content.msg.bizdistrict.length;i++){
			        $('select[name="bizdistrictid"]').append('<option value="'+content.msg.bizdistrict[i].bizdistrictid+'">'+content.msg.bizdistrict[i].bizdistrictname+'</option>');
			   }
			}
			 
		}else{
			if(content.error == true)
			{
			alert(content.msg);
				 //$('#testrestul').html(); 
			}else{
			alert(content);
				// $('#testrestul').html(content); 
			}
		} 
		},
	error: function(content) {   
		 alert('数据获取失败');// $('#testrestul').html(''); 
	  }
   }); 


}
</script>
</body>
</html>